﻿#include "Application.h"
#include "SocketSystem.h"
#include "CommConversion.h"
#include "BaseDlg.h"
#include "TCPServerDlg.h"
#include "TCPClientDlg.h"
#include "UDPDlg.h"
#include "FileDirDlg.h"

Application& Application::Instance()
{
	static Application app{};
	return app;
}

void Application::run()
{
	/*BaseDlg dlg{};
	TCPServerDlg tcp_dlg{};
	tcp_dlg.showDialog();

	TCPClientDlg client_dlg{}; client_dlg.showDialog();
	UDPDlg udp_dlg{}; udp_dlg.showDialog();
	FileDirDlg filedir{}; filedir.showDialog();*/
	
	CommConversion w{};
	w.show();
	q_app.exec();

	//SocketSystemInitialize();

	//QHexView h{};
	//

	////h.setData(&buf);

	//QByteArray buf;
	//buf.resize(1024);

	//QBuffer b;
	//b.setBuffer(&buf);
	//b.open(QIODeviceBase::ReadWrite);

	//h.setData(&b);
	//h.show();

}

Application::Application() :cfg{}, argc{}, argv{}, q_app{ argc,argv }, sock_sys_init{ SocketSystemInitialize() }
{
	
}

Application::~Application()
{
	if(sock_sys_init)
	{
		SocketSystemShutdown();
	}
}
